#!/usr/bin/env python3
import os
import sys
import asyncio
from PyQt6.QtWidgets import QApplication
from PyQt6.QtCore import QEventLoop
from config import ROOT_DIR
from mainwindow import MainWindow
import qasync

def main():
    # 获取项目根目录
    os.chdir(ROOT_DIR)

    # 创建应用和事件循环
    app = QApplication(sys.argv)
    loop = qasync.QEventLoop(app)
    asyncio.set_event_loop(loop)

    # 创建并显示主窗口
    window = MainWindow()
    window.show()

    # 在事件循环中运行
    with loop:
        loop.run_forever()

if __name__ == '__main__':
    main()
